package net.apps.core.meta;

import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;

public class FieldMetaImpl implements Meta {
	
	private final Meta parent_meta;
	private final int id;
	private final String name;
	private final String description;
	
	FieldMetaImpl(Meta parent_meta, Field fld) {
		this.parent_meta = parent_meta;
		AField ann = fld.getAnnotation(AField.class);
		this.id = ann.id();
		String name = ann.name();
		if (name == null || name.length() == 0)
			name = fld.getName();
		this.name = name;
		this.description = ann.description();
	}

	@Override
	public Decl getDeclKind() {
		return Decl.PROTOCOL;
	}

	@Override
	public int getId() {
		return id;
	}

	@Override
	public Meta getType() {
		return MetaFactory.metaOfField;
	}

	@Override
	public Collection<Meta> getConstraints() {
		return Collections.emptyList();
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public String getDescription() {
		return description;
	}

	@Override
	public Meta getParent() {
		return parent_meta;
	}
	
	@Override
	public Collection<Meta> getDecls() {
		return null;
	}

	@Override
	public Meta getTypeDecl(int id) {
		return null;
	}

	@Override
	public Object getValue() {
		return null;
	}

}
